//
//  PKwelcomeViewController.m
//  pantaKills
//
//  Created by 湛凯杰 on 16/8/3.
//  Copyright © 2016年 湛凯杰. All rights reserved.
//      剩下主界面 上添加一些动态效果 直接添加到keepView上

#import "PKwelcomeViewController.h"

#import "AVAudioPlayer+only.h"
#import "PKLoginViewController.h"
#import "PKRegisterViewController.h"
#import "UINavigationController+CustomAnimation.h"
#import "PKRegisterViewController.h"
#import "KeepNewFeatrueView.h"
@interface PKwelcomeViewController ()
@property (nonatomic, strong) KeepNewFeatrueView *keepView;
@property (nonatomic, strong) UIButton *registerButton;
@property (nonatomic, strong) UIButton *loginButton;
@property (nonatomic, strong) AVAudioPlayer * audioplayer;

@end

@implementation PKwelcomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=MAIN_BACKCOLOR;
    
    [self.view addSubview:self.keepView];
    [self.keepView addSubview:self.loginButton];
    [self.keepView addSubview:self.registerButton];
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_login"]]];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}
#pragma mark - 懒加载
- (KeepNewFeatrueView *)keepView
{
    if (!_keepView) {
        _keepView = [[KeepNewFeatrueView alloc] init];
        _keepView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
        
    }
    return _keepView;
}


- (UIButton *)registerButton
{
    if (!_registerButton) {
        _registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
        CGFloat margin = 20;
        CGFloat X = margin;
        CGFloat H = 50;
        CGFloat W = ([UIScreen mainScreen].bounds.size.width - 3 * margin) * 0.5;
        CGFloat Y = [UIScreen mainScreen].bounds.size.height - H - 15;
        _registerButton.frame = CGRectMake(X, Y, W, H);
        [_registerButton setTitle:@"注册" forState:UIControlStateNormal];
        [_registerButton setBackgroundColor:[UIColor blackColor]];
        _registerButton.titleLabel.font = [UIFont systemFontOfSize:18];
        [_registerButton addTarget:self action:@selector(registerClick) forControlEvents:UIControlEventTouchUpInside];
        _registerButton.layer.cornerRadius = 3.0f;
        _registerButton.alpha = 0.4f;
    }
    return _registerButton;
}

- (UIButton *)loginButton
{
    if (!_loginButton) {
        _loginButton = [[UIButton alloc]init];
        
        CGFloat margin = 20;
        CGFloat X = CGRectGetMaxX(self.registerButton.frame) + margin;
        CGFloat H = 50;
        CGFloat W = ([UIScreen mainScreen].bounds.size.width - 3 * margin) * 0.5;
        CGFloat Y = [UIScreen mainScreen].bounds.size.height - H - 15;
        _loginButton.frame = CGRectMake(X, Y, W, H);
        [_loginButton setTitle:@"登录" forState:UIControlStateNormal];
        [_loginButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_loginButton setBackgroundColor:[UIColor whiteColor]];
        [_loginButton addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];
        _loginButton.titleLabel.font = [UIFont systemFontOfSize:18];
        _loginButton.layer.cornerRadius = 3.0f;
        _loginButton.alpha = 0.4f;
    }
    return _loginButton;
}

- (void)registerClick
{
    PKRegisterViewController * regisVC=[[PKRegisterViewController alloc]init];
    [self presentViewController:regisVC animated:YES completion:^{
        
    }];
    
}

- (void)login
{
    PKLoginViewController * loginVC =[[PKLoginViewController alloc]init];
    [self presentViewController:loginVC animated:YES completion:^{
        
    }];
}

@end
